package com.quartz.web;

import com.quartz.service.QuartzOneService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cron")
public class CronController {
    @Autowired
    QuartzOneService  quartzOneService;
    @GetMapping("/stop")
    @ApiOperation("结束")
    public boolean stop() throws Exception{
        return quartzOneService.stop();
    }
    @GetMapping("/three")
    @ApiOperation("三秒")
    public boolean threeSecend() throws Exception{
        return quartzOneService.changeCron("0/3 * * * * ?");
    }
    @GetMapping("/six")
    @ApiOperation("6秒")
    public boolean fourSecend() throws Exception{
        return quartzOneService.changeCron("0/6 * * * * ?");
    }
    @GetMapping("/start")
    @ApiOperation("开始")
    public boolean start() throws Exception{
       return quartzOneService.start();
    }
    @GetMapping("/change")
    @ApiOperation("定制")
    public boolean change(String cron) throws Exception{
        return quartzOneService.changeCron(cron);
    }


}
